using Firestarter.DB.Schema.Logic;
using Firestarter.DM_DB.Logic;
using FireStarterModeller.BO;
using FireStarterModeller.Test;
using NUnit.Framework;

namespace Firestarter.DB_DM.Logic.Test
{
    [TestFixture]
    public class TestDMTypeToDBColumnTypeMapper : TestBase
    {
        

        [Test]
        public void Test_StandardMapping_WhenBool_ShouldConvertToBit()
        {
            //---------------Set up test pack-------------------
            IDMTypeToDBColumnTypeMapper mapper = CreateTypeMapper();
            //---------------Execute Test ----------------------
            var type = mapper.GetDBColumnType("System", "Boolean");
            //---------------Test Result -----------------------
            Assert.AreEqual(DBDataTypes.BIT, type);
        }

        [Test]
        public void Test_StandardMapping_WhenInt32_ShouldConvertToINTEGER()
        {
            //---------------Set up test pack-------------------
            IDMTypeToDBColumnTypeMapper mapper = CreateTypeMapper();
            //---------------Execute Test ----------------------
            var type = mapper.GetDBColumnType("System", "Int32");
            //---------------Test Result -----------------------
            Assert.AreEqual(DBDataTypes.INTEGER, type);
        }
 
        [Test]
        public void Test_StandardMapping_WhenByte_ShouldConvertToVARBINARY()
        {
            //---------------Set up test pack-------------------
            IDMTypeToDBColumnTypeMapper mapper = CreateTypeMapper();
            //---------------Execute Test ----------------------
            var type = mapper.GetDBColumnType("System", "Byte[]");
            //---------------Test Result -----------------------
            Assert.AreEqual(DBDataTypes.VARBINARY, type);
        }

        [Test]
        public void Test_StandardMapping_WhenDateTime_ShouldConvertToDATETIME()
        {
            //---------------Set up test pack-------------------
            IDMTypeToDBColumnTypeMapper mapper = CreateTypeMapper();
            //---------------Execute Test ----------------------
            var type = mapper.GetDBColumnType("System", "DateTime");
            //---------------Test Result -----------------------
            Assert.AreEqual(DBDataTypes.DATETIME, type);
        }

        [Test]
        public void Test_StandardMapping_WhenDecimal_ShouldConvertToDECIMAL()
        {
            //---------------Set up test pack-------------------
            IDMTypeToDBColumnTypeMapper mapper = CreateTypeMapper();
            //---------------Execute Test ----------------------
            var type = mapper.GetDBColumnType("System", "Decimal");
            //---------------Test Result -----------------------
            Assert.AreEqual(DBDataTypes.DECIMAL, type);
        }

        [Test]
        public void Test_StandardMapping_WhenDouble_ShouldConvertToDOUBLE()
        {
            //---------------Set up test pack-------------------
            IDMTypeToDBColumnTypeMapper mapper = CreateTypeMapper();
            //---------------Execute Test ----------------------
            var type = mapper.GetDBColumnType("System", "Double");
            //---------------Test Result -----------------------
            Assert.AreEqual(DBDataTypes.DOUBLE, type);
        }

        [Test]
        public void Test_StandardMapping_WhenInt16_ShouldConvertToSMALLINT()
        {
            //---------------Set up test pack-------------------
            IDMTypeToDBColumnTypeMapper mapper = CreateTypeMapper();
            //---------------Execute Test ----------------------
            var type = mapper.GetDBColumnType("System", "Int16");
            //---------------Test Result -----------------------
            Assert.AreEqual(DBDataTypes.SMALLINT, type);
        }

        [Test]
        public void Test_StandardMapping_WhenString_ShouldConvertToVARCHAR()
        {
            //---------------Set up test pack-------------------
            IDMTypeToDBColumnTypeMapper mapper = CreateTypeMapper();
            //---------------Execute Test ----------------------
            var type = mapper.GetDBColumnType("System", "String");
            //---------------Test Result -----------------------
            Assert.AreEqual(DBDataTypes.VARCHAR, type);
        }

        [Test]
        public void Test_StandardMapping_WhenInt64_ShouldConvertToBIGINT()
        {
            //---------------Set up test pack-------------------
            IDMTypeToDBColumnTypeMapper mapper = CreateTypeMapper();
            //---------------Execute Test ----------------------
            var type = mapper.GetDBColumnType("System", "Int64");
            //---------------Test Result -----------------------
            Assert.AreEqual(DBDataTypes.BIGINT, type);
        }

        [Test]
        public void Test_StandardMapping_WhenByte_ShouldConvertToTINYINT()
        {
            //---------------Set up test pack-------------------
            IDMTypeToDBColumnTypeMapper mapper = CreateTypeMapper();
            //---------------Execute Test ----------------------
            var type = mapper.GetDBColumnType("System", "Byte");
            //---------------Test Result -----------------------
            Assert.AreEqual(DBDataTypes.TINYINT, type);
        }

        [Test]
        public void Test_StandardMapping_WhenSingle_ShouldConvertToSINGLE()
        {
            //---------------Set up test pack-------------------
            IDMTypeToDBColumnTypeMapper mapper = CreateTypeMapper();
            //---------------Execute Test ----------------------
            var type = mapper.GetDBColumnType("System", "Single");
            //---------------Test Result -----------------------
            Assert.AreEqual(DBDataTypes.SINGLE, type);
        } 
        
        [Test]
        public void Test_StandardMapping_WhenGuid_ShouldConvertToUNIQUEIDENTIFIER()
        {
            //---------------Set up test pack-------------------
            IDMTypeToDBColumnTypeMapper mapper = CreateTypeMapper();
            //---------------Execute Test ----------------------
            var type = mapper.GetDBColumnType("System", "Guid");
            //---------------Test Result -----------------------
            Assert.AreEqual(DBDataTypes.UNIQUEIDENTIFIER, type);
        }
        
        [Test]
        public void Test_StandardMapping_WhenChar_ShouldConvertToCHAR()
        {
            //---------------Set up test pack-------------------
            IDMTypeToDBColumnTypeMapper mapper = CreateTypeMapper();
            //---------------Execute Test ----------------------
            var type = mapper.GetDBColumnType("System", "Char");
            //---------------Test Result -----------------------
            Assert.AreEqual(DBDataTypes.CHAR, type);
        }
        
        [Test]
        public void Test_StandardMapping_WhenTimeSpan_ShouldConvertToTIME()
        {
            //---------------Set up test pack-------------------
            IDMTypeToDBColumnTypeMapper mapper = CreateTypeMapper();
            //---------------Execute Test ----------------------
            var type = mapper.GetDBColumnType("System", "TimeSpan");
            //---------------Test Result -----------------------
            Assert.AreEqual(DBDataTypes.TIME, type);
        }

        private static DMTypeToDBColumnTypeMapper CreateTypeMapper()
        {
            return new DMTypeToDBColumnTypeMapper();
        }
        
    }

}